import {api} from './libs/api.js';
let _self;
export const index =  {
	data() {
		return {
			optLock:false,
			formData:{"deliver":{},"images":[]},
			deliver:{},
			deliverShow:false,
			invoiceField:{},
			list1: [{ name: '上传图片'}, {name: '填写资料'}],
			tabIndex:0
		}
	},
	
	mounted() {
		_self = this;
	},
	onReachBottom:function(e){
		/*this.params.page+=1;
		this.initData();*/
	},
	onLoad:function(option) {
		this.formData["id"]=option.id?option.id:0;
		//this.tabSubItem=option.status;
	},
	
	
	methods: {
		async initData(){
			
			this.invoiceField=await api.getInvoiceField({});
			if(this.formData["id"]){
				this.formData = await api.getInfo({"id":this.formData["id"]});
			}
		},
		
		async submitForm(){	
			/*console.log(this.formData);
			return true;*/
			//if(_self.optLock) return true;
			_self.optLock=true;
			let ret= await api.addInvoice(this.formData);
			if(ret=="success"){
				uni.showToast({icon:"none",title:"添加成功！"});
				setTimeout(function(){uni.navigateTo({url:"/pages/invoice/index?status=1"});},2000);　　
			}else{
				_self.optLock=false;
			}
		},
		
		selectDeliver(){
			this.deliverShow=true;
		},
		
		tabClick(item){
			this.tabIndex=item.index;
			//console.log('item', item);
		}
		
				
	},
}